﻿using DTcms.Common;
using DTcms.Web.Mvc.UI;
using System.Collections.Generic;
using System.Data;

namespace DTcms.Web.Plugin.Link
{
    public partial class link 
    {
        /// <summary>
        /// 友情链接列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns>DataTable</returns>
        public DataTable get_link_list(int top, string strwhere)
        {
            DataTable dt = new DataTable();
            dt = new BLL.plugin_link().FillDataSet(top, strwhere, "sort_id asc,add_time desc").Tables[0];
            return dt;
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>List</returns>
        public List<Model.plugin_link> get_link_list(int page_size, int page_index, string strwhere, out int totalcount)
        {
            string _where = "is_lock=0";
            if (!string.IsNullOrEmpty(strwhere))
            {
                _where += " and " + strwhere;
            }

            var resultlist = new BLL.plugin_link().GetQueryPage(page_index, page_size, _where, "sort_id asc,add_time desc");
            totalcount = Utils.ObjToInt(resultlist.TotalItems);
            return resultlist.Items;
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>List</returns>
        public DataTable get_link_table_list(int page_size, int page_index, string strwhere, out int totalcount)
        {
            string _where = "is_lock=0";
            if (!string.IsNullOrEmpty(strwhere))
            {
                _where += " and " + strwhere;
            }

            DataTable resultlist = new BLL.plugin_link().GetList(page_size, page_index, _where, "sort_id asc,add_time desc",out totalcount).Tables[0];
            return resultlist;
        }
    }
}
